﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Char_panel : MonoBehaviour {

	public Text health_text;
	public Slider health_Slider;
	public Character holder;
	void Awake()
    {
        Gamecontrol.Instance.e_leader_change += delegate()
        {
            //target = Gamecontrol.Instance.player_leader.transform;
            if (holder != null) 
            {
            	holder.e_hited -= hited;
            }
            holder = Gamecontrol.Instance.player_leader;
			holder.e_hited += hited;
			health_Slider.maxValue = holder.health;
			health_Slider.value = holder.health_now;
        };
    }
	void Start ()
	{
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	public void hited(Damage damge)
	{
		health_Slider.value -= damge.Hurt;
		health_text.text = health_Slider.value + "/" + health_Slider.maxValue;
	}
}
